package com.nian.hbase.simple.controller;

import com.nian.common.model.ServerResponse;
import com.nian.hbase.base.service.IHBaseService;
import com.nian.hbase.simple.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用途：
 * 开发：zhangmj
 * 日期：2020/4/18 0018 6:47
 */
@RestController
@RequestMapping("test/hbase")
public class TestHBaseController {

    @Autowired
    IHBaseService ihBaseService;

    @PostMapping("put")
    public ServerResponse put(@RequestBody UserModel model) {
        return ServerResponse.createBySuccess(ihBaseService.put(model));
    }

    @PostMapping("getAll")
    public ServerResponse getAll() {
        List list = ihBaseService.scanner(UserModel.class);
        return ServerResponse.createBySuccess(list);
    }

    @PostMapping("addTestData")
    public ServerResponse addTestData() {
        UserModel userModel = new UserModel("汤姆", "004", "18010012004", "Tom","Tom", "2020-04-23");
        return ServerResponse.createBySuccess(ihBaseService.put(userModel));
    }
}
